Repository navigation
fix: surface repeat acp_retrieve cost in the ack (#1430) - #1674
ranxianglei wants to merge 1 commit into
Conversation
Repeated fetches of the same CCR ref re-send the full original every turn with no feedback at the decision point - the root of the #1430 context-bloat loop (the more often we compress, the more aggressively we retrieve). Append a cumulative-cost note to the retrieve ack from the 2nd fetch onward, reusing the existing per-ref count map (no new state, no type change). First fetches stay byte-identical; single-fetch sessions see no change. Host-only, zero structural risk: rides inside the existing tool-result field on every wire, correct in both compression modes.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1621-pr.1674.4c51ff2This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1674.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR 已核对完毕:代码正确、CI 全绿、rebase 到最新 master 后复验通过,可以合并(wire 可见变更,按 §7.4 走人工合并)。 ① 方向关(审原 issue)#1430 里你拍的归因是「取回通道无成本闸门」,修复排序 B2(host-only、零 wire 结构变化)= 在决策点让累计成本可见。本 PR 精确实现 B2: ② 回归审查(既有行为逐项清点)
高危模式排查:无 fail-fast 变吞错、无默认值/阈值漂移(新常量 ③ 代码审查
④ 测试有效性新测试有牙:首次干净(抓阈值误降为 1)、第二次 ⑤ diff 整洁度2 文件 +42/-3,每一行都与 PR 目的相关;无关改动、空白重排、锁文件 churn 均无。✔ 验证数据
非阻塞观察(4 条,都不拦合并)
一句话中文摘要:本 PR 给重复 acp_retrieve 的 ack 加了从第 2 次起的累计成本提示(决策点可见性,B2 方案),首次取回逐字节不变、两模式 wire-safe、测试有牙、CI 与本地 rebase 复验全绿,可以人工合并。 |
Fixes #1430
What & why
#1430: repeated
acp_retrieveof the same stored ref re-sends the full original every turn with no feedback at the decision point. Because CCR stores oversized tool results at arrival and the retrieved text is ephemeral (never enters history, never compressible), a ref the model keeps needing gets pulled back in full on every turn. The owner's field scan found single refs fetched up to x8 (~50+ calls) and one file re-pulled full 9x along a session lineage (~70k tok of pure duplication). This drives the amplification loop: retrieve bytes count toward growth -> faster floor hit -> earlier fold -> more reliance on retrieve ("the more often we compress, the more aggressively we retrieve").This is the B2 fix from the issue's ranked plan - host-only, zero structural risk. It makes the accumulating cost visible at the decision point so the model can self-correct.
Change
src/store.ts::executeRetrieveappends a cumulative-cost note to the retrieve ack from the 2nd fetch of the same ref onward, reusing the existing per-ref count map (recordRetrieveHitnow returns the running count). No new state, no type change, no config change.Example ack on the 3rd fetch of
m00585:Behavior change (disclosure)
Repeated-ref
acp_retrieveacks gain a trailing cost-note line starting at the 2nd fetch onward. First/single fetches are byte-identical to before; sessions that never re-fetch see no change. Wire-safe in both compression modes: the note rides inside the existing tool-result field (proxy mode strips the ephemeral retrieve result; plugin mode carries it as a short, accurate MCP result).Config surface
Unchanged - no field added, renamed, or re-semantics'd.
Not included (deferred to owner decision, per the issue's ranking)
acp_retrieve(ref, lines?/head?/tail?)- highest leverage, cross-repo (acp-kernel contract), human-gated.minToolTokensdefault (4000 -> higher) - default-value product decision.Pre-flight
npm run typecheck- cleannpm test- 3209 pass / 0 fail / 12 skipped (new regression test "acp_retrieve被滥用 导致上下文暴增 #1430: repeat acp_retrieve surfaces a cumulative-cost note in the ack; first fetch stays clean")npm run build- success